# # 函数
# def add(x,y):
#     return x+y
# ret=add(10,20)
# print(ret)
# def say():
#     print("xx")
#     return None
# say()
# ret=say()
# print(ret,type(ret))
#
# def say1():
#     print("dd")
# ret=say1()
# print(ret)
# -------------------------------------------------------
# def check_age(num):
#     if num>=18:
#         print("成年")
#
#     else:
#         return None
# ret=check_age(33)
# print(ret)
# if not ret:
#     print("ff")
# -------------------------------------------------------
# # 函数说明文档
# def add(x,y):
#     """
#     add函数说明
#     :param x: 形参
#     :param y: 形参
#     :return: x+y
#     """
#     return x+y
# ret=add(2,3)#鼠标悬停函数上面可以看出来说明文档
# -------------------------------------------------------
# 全局变量
# def test_a():
#     num=100
#     print(num)
# test_a()
# print(num)
# -------------------------------------------------------------
# num=1000
# def test_a():
#     num=100
#     print(num)
# test_a()
# print(num)
# ---------------------------------------------------------------
# num=1000
# def test_a():
#     global num
#     num=100
#     print(num)
# test_a()
# print(num)
# # 案例
# name=input("输入姓名")
# money=5000000
# def check(bool_1):
#     if bool_1:
#         print("------剩余余额--------")
#         print(money)
#     else:
#         print(money)
# def saving(num):
#     global money
#     money+=num
#     print("--------存钱----------")
#     print("存款成功！")
#     check(False)
# def get(num):
#     global money
#     money-=num
#     print("--------取钱----------")
#     print("取钱成功！")
#     check(False)
# def main():
#     print("查询余额：[输入1]")
#     print("存钱\t\t：[输入2]")
#     print("取钱\t\t：[输入3]")
#     print("退出\t\t：[输入4]")
#     return input("输入数字")
# while True:
#     key=main()
#     if key=='1':
#         check(True)
#         continue
#     elif key=='2':
#         num=int(input("存钱"))
#         saving(num)
#     elif key=='3':
#         num = int(input("取钱"))
#         get(num)
#
#     else:
#         print("退出")
#         break
# --------------------------------------------------
# # 列表
# list=[[1,2,3],[5,6,7],"xxl python"]
# print(list,type(list)
# # 列表下标索引 2种
# list=["Tom","Lily","Jerry"]
# print(list[0])
# print(list[1])
# print(list[2])
# print(list[-1])
# print(list[-2])
# print(list[-3])
# Tom
# Lily
# Jerry
# Jerry
# Lily
# Tom
# ----------------------------------------------
# # 列表：
# 1.可以容纳多个元素 2**63-1 比亿亿还大的多
# 2.内容可以重复
# 3.数据类型可以混装
# 4.有序存储
# list=[21,25,21,23,22,20]
# list.append(31)
# list.extend([29,33,30])
# num1=list[0]
# num2=list[-1]
# num3=list.index(31)
# num4=len(list)
# num5=list.count(31)
# print(list,num1,num2,num3,num4)
# print(num5)
# list.clear()
# print(list)
# list=[21,25,21,23,22,20]
# list.remove(21)#remove 只删除一个元素并且从前向后
# print(list)
# list=[21,25,21,23,22,20]
# del list[4]
# list.insert(3,90)
# print(list)
# ---------------------------------------------------------
# # 练习
# list=[]
# List=[1,2,3,4,5,6,7,8,9,10]
# index=0
# while index<len(List):
#     if(List[index]%2==0):
#         list.append(List[index])
#     index+=1
# print(list)
# list=[]
# for x in List:
#     if x%2==0:
#         list.append(x)
# print(list)
# --------------------------------------------------------
# # 元组 内容不可以修改 但是有特例 元组和列表的嵌套
# list=(1,2,3,4,5)
# print(type(list))
# tuple=("周杰伦",11,["football","music"])
# index=tuple.index(11)
# name=tuple[0]
# tuple[2].remove("football")
# tuple[2].append("coding")
# print(tuple)
# -----------------------------------------------------
# # 字符串 不可修改 只存储字符串 split后得到list
# str1="itheima itcast boxuegu"
# count=str1.count("it")
# print(count)
# new_str1=str1.replace(" ",'|')
# print(new_str1,"  ",str1)
# list=str1.split("|")
# print(list)
# str1="xxititheima itcast boxueguititit"
# str2=str1.strip("it")
# print(str2)
# -----------------------------------------------------
# # 切片
# str="万过薪月，员序程马黑来，nohtyP学"
# ret1=str[::-1][9:14:1]
# print(ret1)
# ret2=str[5:10][::-1]
# print(ret2)
# ret3=str.split("，")[1].replace("来","")[::-1]
# print(ret3)
# -----------------------------------------------------------------------------------------------------------------------------------
# # 集合：去重 数据无序 不可以用下标访问 set{1,2,3,4,5} 混装
# set1=set()#set1={}-->dict
# my_set={"xxl",123,12,12,'s'}
# print(my_set)
# my_set.add("long")
# print(my_set)
# my_set.remove(123)#list 是从前向后删除 这个是直接删除
# print(my_set)
# ret=my_set.pop()#取出原先就没有了
# print(ret)
# print(my_set)
# my_set.clear()
# print(my_set)
# my_set1={"xxl",123,12,12,'s'}
# my_set2={"xxl",12,14,15,16,"x"}
# set3=my_set1.difference(my_set2)
# print(set3)
# my_set1.difference_update(my_set2)
# print(my_set1)
# set4=my_set1.union(my_set2)
# print(set4)
# ----------------------------------------------------------------------------------------------------------------
# # dict 键值对 没有下标索引 key不可以是字典 value可以是任何类型 key不允许重复元素 之前的被之后的覆盖掉
# dict1=dict()
# dict2={}
# dict3={
#     "xxl":{
#         "高数":98,
#         "大英":92
#     },
#     "vn":{
#         "高数":32,
#         "大英":12
#     }
# }
# ret=dict3["xxl"]["高数"]
# print(ret)
# ------------------------------------------------------------------------------------------------------------
# dict 操作
# dict={"xxl":2,"xxf":3}
# print(dict["xxl"])
# dict["xxl"]=12
# print(dict)
# ret=dict.pop("xxl")
# print(ret)
# dict.clear()
# dict={"xxl":2,"xxf":3}
# num=dict.keys()
# print(num)
# -----------------
# # 案例
# dict={
#     "王力宏":{
#         "部门":"科技部",
#         "工资":3000,
#         "级别":1
#     },"周杰伦":{
#         "部门":"市场部",
#         "工资":5000,
#         "级别":2
#     },"林俊杰":{
#         "部门":"市场部",
#         "工资":7000,
#         "级别":3
#     },"zhangxueyou":{
#         "部门":"科技部",
#         "工资":4000,
#         "级别":1
#     },"柳大华":{
#         "部门":"市场部",
#         "工资":6000,
#         "级别":2
#     }
# }
# print(dict)
# for name in dict:
#     if dict[name]["级别"]==1:
#         tempt=dict[name]
#         tempt["级别"]+=1
#         tempt["工资"]+=1000
#         dict[name]=tempt
#
# print(dict)
# ------------------------------------------------------------
# list tuple str set dict通用操作
# dict 比较大小是通过key 字符串比较的
# my_list=[1,2,3,4,5]
# my_tuple=(1,2,3,4,5)
# my_str="abcdefg"
# my_set={1,2,3,4,5}
# my_dict={"key1":1,"key2":2,"key3":3,"key4":4,"key5":5}
# print("list max",max(my_list))
# print("tuple max",max(my_tuple))
# print("str max",max(my_str))
# print("set max",max(my_set))
# print("dict max",max(my_dict))
#
# print("list min",min(my_list))
# print("tuple min",min(my_tuple))
# print("str min",min(my_str))
# print("set min",min(my_set))
# print("dict min",min(my_dict))
#
# print("list len",len(my_list))
# print("tuple len",len(my_tuple))
# print("str len",len(my_str))
# print("set len",len(my_set))
# print("dict len",len(my_dict))
# print("-------------------------------------------")
# print(f"list ->转list {list(my_list)}")
# print(f"tuple ->转list {list(my_tuple)}")
# print(f"str ->转list {list(my_str)}")
# print(f"set ->转list {list(my_set)}")
# print(f"dict ->转list {list(my_dict)}")#只保留key
#
# print(f"list ->转tuple {tuple(my_list)}")
# print(f"tuple ->转tuple {tuple(my_tuple)}")
# print(f"str ->转tuple {tuple(my_str)}")
# print(f"set ->转tuple {tuple(my_set)}")
# print(f"dict ->转tuple {tuple(my_dict)}")#只保留key
#
# print(f"list ->转str {str(my_list)}")
# print(f"tuple ->转str {str(my_tuple)}")
# print(f"str ->转str {str(my_str)}")
# print(f"set ->转str {str(my_set)}")
# print(f"dict ->转str {str(my_dict)}")#保留key和value
#
# print(f"list ->转set {set(my_list)}")
# print(f"tuple ->转set {set(my_tuple)}")
# print(f"str ->转set {set(my_str)}")
# print(f"set ->转set {set(my_set)}")
# print(f"dict ->转set {set(my_dict)}")#只保留key
#
# my_list=[5,3,4,2,1]
# my_tuple=(3,4,1,2,5)
# my_str="acdbfge"
# my_set={2,1,4,3,5}
# my_dict={"key4":1,"key1":2,"key3":3,"key2":4,"key5":5}
#
#
#
# print("sorted()")
#
# print(sorted(my_list))
# print(sorted(my_tuple))
# print(sorted(my_str))
# print(sorted(my_set))
# print(sorted(my_dict))
# # sorted 执行后不会更改原本的
# print(my_list)
# print("sorted reverse")
# print(sorted(my_list,reverse=True))
# print(sorted(my_tuple,reverse=True))
# print(sorted(my_str,reverse=True))
# print(sorted(my_set,reverse=True))
# print(sorted(my_dict,reverse=True))







































